home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1994 November: Tool Chest / Dev.CD Nov 94.toast / Sample Code / Snippets / Toolbox / WDEFColorSample / MakeRatioRGB.a next >
Encoding:
Text File  |  1992-07-15  |  1.4 KB  |  60 lines  |  [TEXT/MPS ]

  1. ;
  2. ; Assembly language routine that does the color mixing
  3. ;
  4. ;void MakeRatioRGB(RGBColor *start, RGBColor *end, RGBColor *dest, short percent)
  5. ;
  6. ; this is the core of the shade mixing code, it takes to values and a ration
  7. ; and returns the combination of the colors.
  8.  
  9.             CASE    ON
  10. MakeRatioRGB    PROC    EXPORT
  11.  
  12. StackFrame    RECORD    {A6Link},DECR
  13. ParamBegin    EQU    *
  14. percent        ds.l    1        ; make sure parameters are in the 
  15. destRGB        ds.l    1        ; correct order for c parameter passing
  16. endRGB        ds.l    1
  17. startRGB    ds.l    1
  18. ParamSize    EQU        ParamBegin-*
  19. RetAddr        ds.l    1
  20. A6Link        ds.l    1
  21. LinkSize    EQU    *
  22.             ENDR
  23.             
  24.             WITH StackFrame
  25.             LINK    A6, #LinkSize
  26. MakeRatio
  27. ;            dc.w    $A9FF            ; debugger
  28.             movem.l    D7/A2, -(SP)
  29.             movea.l    endRGB(A6), A0
  30.             movea.l    startRGB(A6), A1
  31.             movea.l    destRGB(A6), A2
  32.             move.l    percent(A6), D2
  33.             
  34.             mulu    #$1111, D2
  35.  
  36.             move.w    #2, D0
  37. @nextChannel
  38.             MOVEQ    #0, D1                    ; clear high word
  39.             MOVE    (A0)+, D1                ; background color component
  40.             SUB        (A1), D1                ; change from foreground
  41.             SLO        D7                        ; remember if it was negated
  42.             BHS.S    @orderedOK
  43.             NEG        D1                        ; flip if subtraction would overflow
  44. @orderedOK
  45.             mulu    D2, D1                    ; multiply times scale factor
  46.             SWAP    D1                        ; divide by 65K
  47.             TST.B    D7
  48.             BEQ.S    @notFlipped
  49.             NEG.L    D1                        ; flip it
  50. @notFlipped
  51.             add.w    (A1)+, D1
  52.             move.w    D1, (A2)+
  53.             dbra    D0, @nextChannel
  54.             movem.l    (SP)+, D7/A2
  55.             UNLK    A6
  56.             movea.l    (SP)+, A0
  57. ;            adda.l    #ParamSize, SP            ; the c caller does this
  58.             jmp        (a0)
  59.  
  60.             END